home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11inc.lha / X11 / Xkw / CardsUtil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-23  |  3.3 KB  |  88 lines

  1. /*
  2.  * $NCD$
  3.  *
  4.  * Copyright 1992 Network Computing Devices
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of NCD. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  NCD. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Keith Packard, Network Computing Devices
  24.  */
  25.  
  26. typedef struct _Card *CardPtr;
  27.  
  28. typedef enum _CardFace { CardFaceUp, CardFaceDown } CardFace;
  29.  
  30. typedef enum _CardDisplay { 
  31.     CardDisplayTop, CardDisplayBottom, CardDisplayAll, 
  32.     CardDisplaySome, CardDisplayNone
  33. } CardDisplay;
  34.  
  35. typedef struct _Card {
  36.     CardPtr        next, prev;
  37.     CardsCardRec    card;
  38.     CardsCardRec    display;
  39.     CardFace        face;
  40.     Boolean        shouldBeUp;
  41.     Boolean        isUp;
  42.     Widget        widget;
  43.     int            row, col;
  44.     XtPointer        data;
  45. } CardRec;
  46.  
  47. typedef struct _CardStack  *CardStackPtr;
  48.  
  49. typedef struct _CardStack {
  50.     Widget        widget;
  51.     Boolean        horizontal;
  52.     CardDisplay        display;
  53.     int            position;
  54.     int            basePosition;
  55.     CardPtr        first, last;
  56.     CardRec        empty;
  57. } CardStackRec;
  58.  
  59. #define New(t) (t *) malloc(sizeof (t))
  60. #define Dispose(p)  free((char *) p)
  61. #define Some(t,n)   (t*) malloc(sizeof(t) * n)
  62. #define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n))
  63.  
  64. extern Boolean    CardIsInOrder (/* CardPtr, CardPtr */);
  65. extern Boolean    CardIsInSuitOrder (/* CardPtr, CardPtr */);
  66. extern Boolean    CardIsInAlternatingSuitOrder (/* CardPtr, CardPtr */);
  67. extern CardPtr    CardInOrder (/* CardPtr */);
  68. extern CardPtr    CardInSuitOrder (/* CardPtr */);
  69. extern CardPtr    CardInAlternatingSuitOrder (/* CardPtr */);
  70.  
  71. extern CardPtr    CardInReverseOrder (/* CardPtr */);
  72. extern CardPtr    CardInReverseSuitOrder (/* CardPtr */);
  73. extern CardPtr    CardInReverseAlternatingSuitOrder (/* CardPtr */);
  74.  
  75. extern void    CardDisplayStack (/* CardStackPtr */);
  76.  
  77. extern void    CardTurn (/* CardPtr, CardFace, Boolean */);
  78. extern void    CardMove (/* CardStackPtr, CardPtr, CardStackPtr, Boolean */);
  79. extern void    CardMoveCards (/* CardStackPtr, CardPtr, CardPtr, CardStackPtr, CardPtr, Boolean */);
  80. extern void    CardRecordHistoryCallback (/* void (*)(), char * */);
  81. extern Boolean    CardUndo (/* void */);
  82.  
  83. extern void    CardInitStack (/* CardStackPtr, Widget, CardsSuit, Boolean, Boolean, int */);
  84. extern void    CardGenerateStandardDeck (/* CardPtr */);
  85. extern void    CardShuffle (/* CardStackPtr */);
  86. extern void    CardInitHistory (/* void */);
  87. extern int    CardNextHistory (/* void */);
  88.